package com.ouc.eddyAlgorithm.controller;

import com.ouc.common.annotation.Log;
import com.ouc.common.core.controller.BaseController;
import com.ouc.common.core.domain.AjaxResult;
import com.ouc.common.core.page.TableDataInfo;
import com.ouc.common.enums.BusinessType;
import com.ouc.common.utils.poi.ExcelUtil;
import com.ouc.eddyAlgorithm.domain.VgForecast;
import com.ouc.eddyAlgorithm.service.IVgForecastService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import java.util.List;
import org.springframework.web.bind.annotation.*;

/**
 * vg涡旋预测Controller
 *
 * @author b504
 * @date 2023-03-09
 */
@Controller
@CrossOrigin
@RequestMapping("/system/vgForecast")
public class VgForecastController extends BaseController {
  private String prefix = "system/vgForecast";

  @Autowired
  private IVgForecastService vgForecastService;

//  @RequiresPermissions("system:vgForecast:view")
  @GetMapping()
  public String vgForecast() {
    return prefix + "/vgForecast";
  }

  /**
   * 查询vg涡旋预测列表
   */
//  @RequiresPermissions("system:vgForecast:list")
  @PostMapping("/list")
  @ResponseBody
  public TableDataInfo list(VgForecast vgForecast, @RequestParam(value = "startPageFlag", required = false, defaultValue = "true") boolean startPageFlag) {
    if(startPageFlag){
      startPage();
    }
    List<VgForecast> list = vgForecastService.selectVgForecastList(vgForecast);
    return getDataTable(list);
  }

  /**
   * 导出vg涡旋预测列表
   */
//  @RequiresPermissions("system:vgForecast:export")
  @Log(title = "vg涡旋预测", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  @ResponseBody
  public AjaxResult export(VgForecast vgForecast) {
    List<VgForecast> list = vgForecastService.selectVgForecastList(vgForecast);
    ExcelUtil<VgForecast> util = new ExcelUtil<VgForecast>(VgForecast.class);
    return util.exportExcel(list, "vg涡旋预测数据");
  }

  /**
   * 新增vg涡旋预测
   */
  @GetMapping("/add")
  public String add() {
    return prefix + "/add";
  }

  /**
   * 新增保存vg涡旋预测
   */
//  @RequiresPermissions("system:vgForecast:add")
  @Log(title = "vg涡旋预测", businessType = BusinessType.INSERT)
  @PostMapping("/add")
  @ResponseBody
  public AjaxResult addSave(VgForecast vgForecast) {
    return toAjax(vgForecastService.insertVgForecast(vgForecast));
  }

  /**
   * 修改vg涡旋预测
   */
//  @RequiresPermissions("system:vgForecast:edit")
  @GetMapping("/edit/{id}")
  public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
    VgForecast vgForecast = vgForecastService.selectVgForecastById(id);
    mmap.put("vgForecast", vgForecast);
    return prefix + "/edit";
  }

  /**
   * 修改保存vg涡旋预测
   */
//  @RequiresPermissions("system:vgForecast:edit")
  @Log(title = "vg涡旋预测", businessType = BusinessType.UPDATE)
  @PostMapping("/edit")
  @ResponseBody
  public AjaxResult editSave(VgForecast vgForecast) {
    return toAjax(vgForecastService.updateVgForecast(vgForecast));
  }

  /**
   * 删除vg涡旋预测
   */
//  @RequiresPermissions("system:vgForecast:remove")
  @Log(title = "vg涡旋预测", businessType = BusinessType.DELETE)
  @PostMapping("/remove")
  @ResponseBody
  public AjaxResult remove(String ids) {
    return toAjax(vgForecastService.deleteVgForecastByIds(ids));
  }
}
